xen: do not merge reserved pages in free_heap_pages()
authorPenny Zheng <Penny.Zheng@arm.com>
Tue, 16 Aug 2022 02:36:52 +0000 (10:36 +0800)
committerJulien Grall <jgrall@amazon.com>
Wed, 24 Aug 2022 09:36:20 +0000 (10:36 +0100)
commit7d3f8a2a26f2fd9c4d830820b8ad68af4e91f409
treeeed658675e9c042f05f9e73d464737e1f9e1776c
parentfc151829bac48f05a307bfd5ad450b3c0ae2a808
xen: do not merge reserved pages in free_heap_pages()

The code in free_heap_pages() will try to merge pages with the
successor/predecessor if pages are suitably aligned. So if the pages
reserved are right next to the pages given to the heap allocator,
free_heap_pages() will merge them, and give the reserved pages to heap
allocator accidentally as a result.

So in order to avoid the above scenario, this commit updates free_heap_pages()
to check whether the predecessor and/or successor has PGC_static set,
when trying to merge the about-to-be-freed chunk with the predecessor
and/or successor.

Suggested-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Penny Zheng <penny.zheng@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
xen/common/page_alloc.c